package cn.edu.xmist.state;

/**
 * 上下文
 */
public class Context {

    /**
     * 状态1
     */
    public final static State STATE1 = new ConcreteState1Impl();
    /**
     * 状态2
     */
    public final static State STATE2 = new ConcreteState2Impl();

    /**
     * 当前状态（核心点在于状态胡改变）
     */
    private State currentState;

    public void setCurrentState(State currentState) {
        this.currentState = currentState;
        /**
         * todo:状态切换
         */
        this.currentState.setContext(this);
    }

    /**
     * 行为委托
     */
    public void handle1() {
        this.currentState.handle1();
    }

    /**
     * 行为委托
     */
    public void handle2() {
        this.currentState.handle2();
    }
}
